package Utility.Utility;

import java.io.File;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;

public class XmlToJavaUnmarshalling {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		try {
			JAXBContext jc= JAXBContext.newInstance(DataFeed.class);
			Unmarshaller u= jc.createUnmarshaller();
			File f=new File("D:\\FreelanceSpace\\Utility\\src\\main\\java\\DATAFEED.xml");
			//JAXBElement<DataFeed> element=(JAXBElement)u.unmarshal(f);
			DataFeed dataFeed=(DataFeed)u.unmarshal(f);
			System.out.println(""+dataFeed.getMessage());
			if(dataFeed.getUrls() != null && dataFeed.getUrls().size() > 0)
			{
				for(MyURL myURL:dataFeed.getUrls())
				{
					System.out.println("URL NAME: "+myURL.getName()+" VALUE: "+myURL.getUrl());
				}
			}
		} catch (JAXBException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}
